package Thread_;

    //线程中断 1
public class Thread08 {
    private static boolean isQuite=false;//设置静态中断变量
    public static void main(String[] args) {
//        final boolean isQuite=false;
        Thread t=new Thread(()->{
            while(!isQuite){//以该中断变量为循环条件
                System.out.println("Thread 线程正在工作!!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread 线程结束!!");
        });
        t.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("3s后 Thread线程结束");
        isQuite=true;//借助中断变量,修改循环状态
    }
}
